package algorithm;

import java.util.Arrays;

public class Demo01 {//冒泡排序（两层循环嵌套）----每一次都是交换出一个最大的到最后面，大的循环要循环i-1次
    public static void main(String[] args) {
        int[] arrInt = {1,5,8,2,4,9,0,5,8,20,56,36,11,47};
        for (int i = 0; i < arrInt.length-1; i++) {
            for (int j = 0; j < arrInt.length-i-1; j++) {
                if(arrInt[j]>arrInt[j+1]){
                    int temp = arrInt[j];
                    arrInt[j]=arrInt[j+1];
                    arrInt[j+1]=temp;
                }
            }
        }
        System.out.println(Arrays.toString(arrInt));
    }
}
